<?php
namespace app\admin\behavior;

use think\Request;

class CORS 
{
    public function run(Request $request, $params)
    {
        // 行为逻辑
        //header('Access-Control-Allow-Origin: *');
        if($_SERVER['HTTP_HOST'] == "localhost" || $_SERVER['HTTP_HOST'] == "127.0.0.1") {
			$domain = "http://localhost:8080";
		}else {
			$domain = "http://managementsystem.ikanmore.com";
		}
        header("Access-Control-Allow-Origin: " . $domain);
        header("Access-Control-Allow-Headers: token, Origin, X-Requested-With, Content-Type, Accept, Authorization");
        header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE');
        header('Access-Control-Allow-Credentials:true');

        if($request->isOptions()){
            exit();
        }
    }
}
?>